package com.mapreduce;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

public class PhonePartitioner extends Partitioner<Text,Text> {
    @Override
    public int getPartition(Text o, Text o2, int numPartitions) {
        // 将138、189、188开头的收集号码整理出来
        // o:k2(电话号)         o2:v2(姓名)
        String phone = o.toString();
        if (phone.startsWith("138")){
            return 0;
        }else if (phone.startsWith("189")){
            return 1;
        }else {
            return 2;
        }
    }
}
